import App from './App'
import request from './common/request';
import './routeIntercept.js';
import emotion from './common/emotion.js';
import * as enums from './common/enums.js';
import * as date from './common/date';
import * as socketApi from './common/wssocket';
import * as messageType from './common/messageType';
import * as pinia from 'pinia';
import useChatStore from '@/store/chatStore.js'
import useFriendStore from '@/store/friendStore.js'
import useGroupStore from '@/store/groupStore.js'
import useConfigStore from '@/store/configStore.js'
import useUserStore from '@/store/userStore.js'
import useCompanyStore from '@/store/companyStore.js'
import useCooperateStore from '@/store/cooperateStore.js'
import useNoticeStore from '@/store/noticeStore.js'
import useEnableStore from '@/store/enableStore.js'
import * as Vue from 'vue'
import uviewPlus from '@/uni_modules/uview-plus'
import customTabbar from "@/components/custom-tabbar/custom-tabbar.vue";
import share from '@/utils/share.js'
import {
	globalMethod
} from './utils/globalMethod';
import {
	isNullOrEmpty
} from './utils';
import {
	createSSRApp,
} from 'vue'
// #ifdef H5
import * as recorder from './common/recorder-h5';
// #endif
// #ifndef H5
import * as recorder from './common/recorder-app';
// #endif
// import VConsole from 'vconsole'
// new VConsole();
export function createApp() {
	const app = createSSRApp(App)
	app.mixin(share)
	app.use(uviewPlus);
	app.use(pinia.createPinia());
	app.component('customTabbar',customTabbar)
	app.config.globalProperties.$http = request;
	app.config.globalProperties.$wsApi = socketApi;
	app.config.globalProperties.$msgType = messageType;
	app.config.globalProperties.$emo = emotion;
	app.config.globalProperties.$enums = enums;
	app.config.globalProperties.$date = date;
	app.config.globalProperties.$rc = recorder;
	// 初始化时再挂载store对象
	app.config.globalProperties.$mountStore = () => {
		app.config.globalProperties.noticeStore = useNoticeStore();
		app.config.globalProperties.cooperateStore = useCooperateStore();
		app.config.globalProperties.companyStore = useCompanyStore();
		app.config.globalProperties.chatStore = useChatStore();
		app.config.globalProperties.friendStore = useFriendStore();
		app.config.globalProperties.groupStore = useGroupStore();
		app.config.globalProperties.configStore = useConfigStore();
		app.config.globalProperties.userStore = useUserStore();
		app.config.globalProperties.enableStore = useEnableStore();
	}
	// 全局方法
	globalMethod(app)
	return {
		app,
		pinia
	}
}